import React,{useContext, useState} from 'react'
import { createContext } from 'react'

const C = createContext({
  name:"hanu  yuzuru",
  // setName:(value)
});

const Con = () => {  
  const [name,setName] = useState('hanu  yuzuru')
  return (
    <C.Provider value={{name}}>
      这是我的名字{name}
    </C.Provider>
  )
}  
const Context = () => {  
  // const [name,setName] = useState('hanu  yuzuru')
  const value = useContext(C)   

  const hangdle = (e) => {
    setName(e.target.value)
  }
  return (
    <C.Provider value={{name}}>
      这是我的名字{value.name}
      {/* <input type="text" onChange={hangdle}/> */}
      {/* <button onClick={hangdle}>设置名字:</button>  */}
    </C.Provider>
  )
}
 

export default Context
